﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Systemudvikling___Larman_Projekt___06._02._2012_
{
    class Sale
    {
        private ArrayList lineItems = new ArrayList();
        private DateTime date = new DateTime();
        private bool isCompleted = false;
        private Payment payment;

        public double getBalance()
        {
            return (payment.getAmount() - (getTotal()));
        }

        public void becomeComplete()
        {
            isCompleted = true;
        }

        public bool isComplete()
        {
            return isCompleted;
        }

        public void makeLineItem(ProductDescription desc, int quantity)
        {
            lineItems.Add(new SalesLineItem(desc, quantity));
        }

       	public double getTotal()
	    {
            double total = 0;
            double subtotal = 0;
      
		    foreach ( SalesLineItem lineItem in lineItems )
		    {
			    subtotal = lineItem.getSubtotal();
			    total = total + subtotal;
		    }
		    return total;
	    }

        public void makePayment(double cashTendered)
        {
            payment = new Payment(cashTendered);
        }
    }
}
